home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / utility1 / gs261src.zip / SHC.H < prev    next >
Text File  |  1993-05-13  |  2KB  |  66 lines

  1. /* Copyright (C) 1992 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* shc.h */
  20. /* Common definitions for filters using Huffman coding */
  21.  
  22. /*
  23.  * These definitions are valid for code lengths up to 16 bits
  24.  * and non-negative decoded values up to 15 bits.
  25.  */
  26.  
  27. /* ------ Encoding tables ------ */
  28.  
  29. /* Define the structure for the encoding tables. */
  30. typedef struct hce_code_s {
  31.     ushort code;
  32.     ushort code_length;
  33. } hce_code;
  34. #define hce_entry(c, len) { c, len }
  35.  
  36. typedef struct hce_table_s {
  37.     uint count;
  38.     hce_code *codes;
  39. } hce_table;
  40.  
  41. /* ------ Decoding tables ------ */
  42.  
  43. /*
  44.  * Define the structure for the decoding tables.
  45.  * First-level nodes are either leaves, which have
  46.  *    value = decoded value
  47.  *    code_length <= initial_bits
  48.  * or non-leaves, which have
  49.  *    value = the index of a sub-table
  50.  *    code_length = initial_bits + the number of additional dispatch bits
  51.  * Second-level nodes are always leaves, with
  52.  *    code_length = the actual number of bits in the code - initial_bits.
  53.  */
  54. #define hcd_value_error (-1)
  55.  
  56. typedef struct hcd_code_s {
  57.     short value;
  58.     ushort code_length;
  59. } hcd_code;
  60.  
  61. typedef struct hcd_table_s {
  62.     uint count;
  63.     uint initial_bits;
  64.     hcd_code *codes;
  65. } hcd_table;
  66.